// pages/studyWord/studyReport/studyReport.js
const app = getApp();
let tool = require('../../../utils/tool.js');
const httpUtils = require('../../../utils/httpUtils.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    pageName: '学习报告',
    navH: app.globalData.navHeight,
    windowHeight: 0,
    imageUrl: app.globalData.imageurl,
    accuracy: 0,//正确率
    credit: 0,//学分
    diamond: 0,//易学币
    study: 0,//已识记
    unknown: 0,//生词
    time: 0,//学习时长
    reportId:0,
  },
  //请求学习报告
  getreport: function () {
    let that = this;
    wx.showLoading({
      title: '',
      mask: true
    })
    httpUtils.getreport({
      access_token: app.globalData.studentInfo.access_token ? app.globalData.studentInfo.access_token : app.globalData.access_token,
      id: this.data.reportId,
    }).then((res) => {
      console.log(res);
      let timeStr = res.data.time / 60;
      timeStr = timeStr.toFixed(0);
      that.setData({
        accuracy: res.data.accuracy,
        credit: res.data.credit,
        diamond: res.data.diamond,
        time: timeStr,
        unknown: res.data.err_num,
        study: res.data.all_num,
      })

    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that=this;
    console.log(this.data.navH);
    this.data.reportId = options.reportId;
    console.log(this.data.reportId);
    this.getreport();
  },

  //点击继续学习按钮
  continueStudy: function () {
    wx.navigateBack({
      delta: 1
    })
  },
  //休息一会
  goHome: function () {
    wx.switchTab({
      url: '/pages/index/index',
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})